package com.qs.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qs.model.entity.Goods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商品表 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-03-23
 */
@Mapper
public interface GoodsMapper extends BaseMapper<Goods> {

    /**
     * 根据用户的浏览量获取前5个商品图片作为轮播图
     * @return
     */
    @Select("SELECT image FROM qs_goods order by browse desc limit 5")
    List<String> findIndexImage();

    /**
     * 获取首页热卖商品(销量最高的15条数据，后按浏览量排序)
     */
    @Select("SELECT * FROM qs_goods where status = '上架' order by sale desc,browse desc limit 15")
    List<Goods> findIndexHotGoods();

    /**
     * 获取首页猜你喜欢商品(浏览量最高的24条数据，后按销量排序)
     */
    @Select("SELECT * FROM qs_goods where status = '上架' order by browse desc,sale desc limit 24")
    List<Goods> findRecommendGoods();

    /**
     * 根据用户的浏览量获取前5个商品图片作为轮播图,获取商品id
     * @return
     */
    @Select("SELECT id FROM qs_goods order by browse desc limit 5")
    List<Integer> findIndexGoodsId();
}
